﻿<UserControl x:Class="PocketBook.Views.Designs.GridPageView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:Controls="clr-namespace:PocketBook.Controls" mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <UserControl.Resources>
        <SolidColorBrush x:Key="GridLineBrush" Color="DodgerBlue" />
    </UserControl.Resources>

    <Controls:IntegralPanel Margin="10" UnitSize="{Binding Spacing}">
        <Border BorderBrush="{StaticResource GridLineBrush}" BorderThickness="1">
            <!-- Not sure which of these approaches is more effective. It seems the first one yields
            better pixel snapping -->
            
            <Grid>
                <Controls:ParallelLines Stroke="{StaticResource GridLineBrush}" Spacing="{Binding Spacing}" />
                <Controls:ParallelLines Stroke="{StaticResource GridLineBrush}" Spacing="{Binding Spacing}" >
                    <Controls:ParallelLines.LayoutTransform>
                        <RotateTransform CenterX="0.5" CenterY="0.5" Angle="270" />
                    </Controls:ParallelLines.LayoutTransform>
                </Controls:ParallelLines>
            </Grid>

            <!-- Using a tiling brush...
            <Rectangle>
                <Rectangle.Fill>
                    <VisualBrush x:Name="GridBrush"  TileMode="Tile" Stretch="Uniform" Viewport="{Binding CellBounds}" ViewportUnits="Absolute">
                        <VisualBrush.Visual>
                            <Border Width="{Binding ElementName=GridBrush, Path=Viewport.Width}" 
                                    Height="{Binding ElementName=GridBrush, Path=Viewport.Height}" BorderBrush="{StaticResource GridLineBrush}" BorderThickness="0,0,1,1" />
                        </VisualBrush.Visual>
                    </VisualBrush>
                </Rectangle.Fill>
            </Rectangle>
            -->

        </Border>
    </Controls:IntegralPanel>
</UserControl>
